package Eyjafjalla.action;

import basemod.ReflectionHacks;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.ReducePowerAction;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.FlightPower;

public class ReduceFlightAction extends AbstractGameAction {
    public ReduceFlightAction(AbstractCreature owner){
        this.target = owner;
    }

    @Override
    public void update() {
        if(this.target!=null){
            AbstractPower flight = target.getPower(FlightPower.POWER_ID);
            if(flight!=null){
                int amt = ReflectionHacks.getPrivate(flight,FlightPower.class,"storedAmount");
                if(amt>1){
                    ReflectionHacks.setPrivate(flight,FlightPower.class,"storedAmount",amt-1);
                    addToTop(new ReducePowerAction(target,target,flight,1));
                }
            }
        }

        this.isDone = true;
    }
}
